package cn.chenc.framework.jpa.exception;

/**
 * 　@description: service 异常
 * 　@author secret
 * 　@date 2021/6/5 23:31
 *
 */
public class ServiceException extends Exception {
    private static final long serialVersionUID = 1L;
    private String module;
    private String code = "500";
    private Object[] args;
    private String msg;

    public ServiceException(String msg) {
        super(msg);
        this.msg = msg;
    }

    public ServiceException(String code, Object[] args) {
        this.code = code;
        this.args = args;
    }

    public ServiceException(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ServiceException(String module, String code, Object[] args) {
        this.module = module;
        this.code = code;
        this.args = args;
    }

    public ServiceException(String module, String code, Object[] args, String msg) {
        this.module = module;
        this.code = code;
        this.args = args;
        this.msg = msg;
    }

    public ServiceException(Throwable throwable) {
        super(throwable);
    }

    public ServiceException(String msg, Throwable e) {
        super(msg, e);
        this.msg = msg;
    }

    public ServiceException(String msg, String code, Throwable e) {
        super(msg, e);
        this.msg = msg;
        this.code = code;
    }

    @Override
    public String toString() {
        return this.getClass() + "{" + "module='" + this.module + '\'' + ", message='" + this.getMessage() + '\'' + '}';
    }

    public String getModule() {
        return this.module;
    }

    public String getCode() {
        return this.code;
    }

    public Object[] getArgs() {
        return this.args;
    }

    public String getMsg() {
        return this.msg;
    }

    public void setModule(final String module) {
        this.module = module;
    }

    public void setCode(final String code) {
        this.code = code;
    }

    public void setArgs(final Object[] args) {
        this.args = args;
    }

    public void setMsg(final String msg) {
        this.msg = msg;
    }
}
